/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.gtm.base.str;

import bgu.ppm.gtm.base.MutableStrategy;
import org.junit.Test;

/**
 *
 * @author User
 */
public class StrategyImplemntationsBenchmark {

    @Test
    public void testBenchmark() {
        final int numVars = 10000;
        final int maxDomain = 2;
        MutableStrategy[] strategies = {new BitmapStrategy(numVars, maxDomain, 0), new IntArrayStrategy(numVars, 0)};
        int warmupIterations = 10000;
        int iterations = 10000000;
        int stam = 0;
        System.out.println("warmup:");
        for (MutableStrategy s : strategies) {
            for (int i = 0; i < warmupIterations; i++) {
                s.set(i % numVars, i % maxDomain);
                stam += s.get(i % numVars);
            }
        }

        for (MutableStrategy s : strategies) {
            long time = System.nanoTime();
            for (int i = 0; i < warmupIterations; i++) {
                s.set(i % numVars, i % maxDomain);
                stam += s.get(i % numVars);
            }
            final long delta = System.nanoTime() - time;

            System.out.println("Time For: " + s.getClass().getSimpleName() + " " + delta + " nano / " + ((double) delta / Math.pow(10, 9)) + " sec.");
        }
    }
}
